<style>
  .ivu-input[disabled], fieldset[disabled] .ivu-input {
    background-color: white;
    opacity: 1;
    cursor: not-allowed;
    color: #515A6E;
  }
  .ivu-select-disabled .ivu-select-selection {
    background-color: white;
    opacity: 1;
    cursor: not-allowed;
    color: #515A6E;
  }
  .ivu-select-input[disabled] {
    cursor: not-allowed;
    color: #515A6E;
    -webkit-text-fill-color: #515A6E;
}
</style>
<template>
    <div class="form-block-inner">
      <Form :model="formInfo" label-position="top" ref="addBaseForm">
        <div class="title-style">查询条件</div>
        <Row :gutter="16">
          <Col span="8">
            <FormItem label="证件号码：">
              <Input type="text" v-model="formInfo.card_no" placeholder="请输入证件号码"/>
            </FormItem>
          </Col>
          <Col span="3" v-if="editFlag">
            <Button type="primary" :loading="saving" class="save-btn mr20" long @click="getuserbycardno (formInfo.card_no)">查 询</Button>
          </Col>
        </Row>
        <div class="title-style">人员基本信息</div>
        <Row :gutter="16">
          <Col span="5">
            <FormItem label="姓名：" prop="name">
              <Input type="text" v-model="formInfo.name" placeholder="请输入姓名"/>
            </FormItem>
          </Col>
          <Col span="5">
            <FormItem>
              <template slot="label">
                性别：
              </template>
              <RadioGroup v-model="formInfo.sex">
                <Radio label="男">男</Radio>
                <Radio label="女">女</Radio>
              </RadioGroup>
            </FormItem>
          </Col>
          <Col span="5">
            <FormItem>
              <template slot="label">
                证件类型：
              </template>
              <Select v-model="formInfo.card_type" placeholder="请选择证件类型"
                      @on-change="ruleValidate.card_no[0].card_type=formInfo.card_type">
                <Option value="1">身份证</Option>
                <Option value="2">军官证</Option>
                <Option value="3">护照</Option>
                <Option value="4">港澳通行证</Option>
              </Select>
            </FormItem>
          </Col>
          <Col span="9">
            <FormItem label="证件号码：" prop="card_no">
              <Input type="text" v-model="formInfo.card_no" placeholder="请输入证件号码"/>
            </FormItem>
          </Col>
        </Row>
        <Row :gutter="16">
          <Col span="5">
            <FormItem label="联系电话：" prop="tel">
              <Input type="text" v-model="formInfo.tel" placeholder="请输入联系电话"/>
            </FormItem>
          </Col>
          <Col span="5">
            <FormItem label="职业：" prop="occupation">
              <Select v-model="formInfo.occupation" placeholder="请选择职业" filterable>
                <Option v-for="obj in occupationList" :value="obj.name" :key="obj.id">{{obj.name}}</Option>
              </Select>
            </FormItem>
          </Col>
          <Col span="5">
            <FormItem label="是否采取安防设备管控：" prop="is_monitoring">
              <Select v-model="formInfo.is_monitoring" placeholder="请选择" filterable>
                <Option value="0">是</Option>
                <Option value="1">否</Option>
              </Select>
            </FormItem>
          </Col>
          <!-- <Col v-if="formInfo.is_monitoring==='0'" span="5">
            <FormItem label="采取安防设备管控：" prop="is_monitoring">
              <Select v-model="formInfo.monitoring_type" placeholder="请选择安防设备管控" filterable>
                <Option v-for="obj in monitoring_typeList" :value="obj.value" :key="obj.id">{{obj.label}}</Option>
              </Select>
            </FormItem>
          </Col>
          <Col v-if="formInfo.monitoring_type==='99' && formInfo.is_monitoring==='0'" span="5">
            <FormItem label="采取安防设备管控：" prop="is_monitoring">
              <Input type="text" v-model="formInfo.monitoring_type_detail" placeholder="请输入采取安防设备管控"/>
            </FormItem>
          </Col> -->
          <Col v-if="formInfo.is_monitoring === '0'" span="5">
            <FormItem label="采取安防设备管控：" prop="is_monitoring">
              <Select v-model="formInfo.monitoring_types" multiple placeholder="请选择安防设备管控" filterable @on-change="monitoringTypesChage()">
                <Option v-for="obj in monitoring_typeList" :value="obj.value" :key="obj.id">{{obj.label}}</Option>
              </Select>
            </FormItem>
          </Col>
          <Col span="5" v-if="ishave99 && formInfo.is_monitoring==='0'">
            <FormItem prop="monitoring_type_detail">
              <template slot="label">
                采取安防设备管控：
              </template>
              <Input type="text" v-model="formInfo.monitoring_type_detail" placeholder="请输入采取安防设备管控"/>
            </FormItem>
          </Col>
        </Row>
        <Row :gutter="16">
          <Col span="5">
            <FormItem prop="area1">
              <template slot="label">
                住址：
                <Icon type="md-help-circle" class="help-tip" @click="showHelp(3)"/>
              </template>
              <Select v-model="formInfo.area1" placeholder="区/县" filterable @on-change="perChange(1, false)">
                <Option v-for="obj in addressInfo.list1" :value="obj.title" :key="obj.id">{{obj.title}}</Option>
              </Select>
            </FormItem>
          </Col>
          <Col span="5">
            <FormItem label="ㅤ" prop="area2">
              <Select v-model="formInfo.area2" placeholder="街道" filterable @on-change="perChange(2, false)">
                <Option v-for="obj in addressInfo.list2" :value="obj.title" :key="obj.id">{{obj.title}}</Option>
              </Select>
            </FormItem>
          </Col>
          <Col span="5" >
            <FormItem v-if="company_type=='1'" label="ㅤ" prop="area3">
              <Select v-model="formInfo.area3" placeholder="社区" filterable>
                <Option v-for="obj in addressInfo.list3" :value="obj.title" :key="obj.id">{{obj.title}}</Option>
              </Select>
            </FormItem>
            <FormItem v-else label="ㅤ" prop="area5">
              <Input type="text" v-model="formInfo.area5" placeholder="村"/>
            </FormItem>
          </Col>
          <Col span="9">
            <FormItem label="ㅤ" prop="address">
              <Input type="text" v-model="formInfo.address" placeholder="具体地址"/>
            </FormItem>
          </Col>
        </Row>

        <div class="title-style">在沈情况</div>
        <Row :gutter="16">
           <Col span="6">
            <FormItem label="人员类型（一级）：" prop="user_control_type1">
              <Select v-model="formInfo.user_control_type1" @on-change="changeuserControlType1()">
                <Option v-for="obj in userControlType1" :value="obj.value" :key="obj.value">{{obj.label}}</Option>
              </Select>
            </FormItem>
          </Col>
          <Col span="6" v-if="userControlType2.length > 0">
            <!-- <FormItem label="人员类型（二级）：" v-if="formInfo.supervise_start === '6'">
              <Select v-model="formInfo.user_control_type2">
                <Option v-for="obj in userControlType2" :value="obj.value" :key="obj.value">{{obj.label}}</Option>
              </Select>
            </FormItem> -->
            <FormItem label="人员类型（二级）：" v-show="formInfo.supervise_start === '6'">
              <Select v-model="formInfo.user_control_type2" @on-change="changeuser_control_type2">
                <Option v-for="obj in userControlType2" :value="obj.value" :key="obj.value">{{obj.label}}</Option>
              </Select>
            </FormItem>
            <FormItem label="人员类型（二级）：" v-show="formInfo.supervise_start !== '6'" prop="user_control_type2">
              <Select v-model="formInfo.user_control_type2" @on-change="changeuser_control_type2">
                <Option v-for="obj in userControlType2" :value="obj.value" :key="obj.value">{{obj.label}}</Option>
              </Select>
            </FormItem>
          </Col>
          <Col span="6" v-if="formInfo.user_control_type1 === '1' || formInfo.user_control_type1 === '5'
          || formInfo.user_control_type1 === '3' || formInfo.user_control_type1 === '6'">
            <FormItem label="是否从事进口冷链食品相关工作返乡人员：" prop="cold_chain_user">
              <Select v-model="formInfo.cold_chain_user" placeholder="请选择" filterable>
                <Option value="1">是</Option>
                <Option value="0">否</Option>
              </Select>
            </FormItem>
          </Col>
          <!-- <Col span="6" v-if="formInfo.user_control_type1 === '2'"> -->
          <Col span="6" v-if="isshowfollow_person">
            <FormItem prop="follow_person" label="密接相关人：">
              <Select v-model="formInfo.follow_person" placeholder="请选择密接相关人" filterable>
                <Option v-for="obj in followPersonList" :value="obj.value" :key="obj.label">{{obj.label}}</Option>
              </Select>
            </FormItem>
          </Col>
        </Row>
        <Row :gutter="16">
          <!-- <Col span="6">
            <FormItem label="出入状态：">
              <RadioGroup v-model="formInfo.inout_state">
                <Radio label="1">入沈人员</Radio>
                <Radio label="2">离沈人员</Radio>
              </RadioGroup>
            </FormItem>
          </Col> -->
          <!-- <Col span="6">
            <FormItem label="来沈前经过地类型：">
              <Select v-model="formInfo.arrive_address_type">
                <Option v-for="obj in arriveAddressTypeList" :value="obj.value" :key="obj.value">{{obj.label}}</Option>
              </Select>
            </FormItem>
          </Col>
          <Col span="18">
            <FormItem label="来沈前经过地：">
              <Input type="text" v-model="formInfo.arrive_address"/>
            </FormItem>
          </Col> -->
          <Col span="6">
            <FormItem label="管控状态："  prop="supervise_start">
              <Select v-model="formInfo.supervise_start" placeholder="请选择管控状态" filterable @on-change="changeGkState">
                <Option v-for="obj in superviseTypeList" :value="obj.value" :key="obj.label">{{obj.label}}</Option>
              </Select>
            </FormItem>
          </Col>
          <Col span="6" v-if="formInfo.supervise_start=='1'">
            <FormItem prop="is_transfer" label="居家隔离状态：">
              <Select v-model="formInfo.is_transfer" placeholder="请选择居家隔离状态" filterable>
                <Option v-for="obj in isTransferList" :value="obj.value" :key="obj.label">{{obj.label}}</Option>
              </Select>
              <!-- <Select v-model="formInfo.is_transfer" placeholder="是否待转运：">
                <Option value="1">是</Option>
                <Option value="0">否</Option>
              </Select> -->
            </FormItem>
          </Col>
          <Col span="6">
            <FormItem prop="supervise_time">
              <template slot="label">
                本次管控开始日期：
              </template>
              <DatePicker type="date" placeholder="选择日期" style="width: 100%" v-model="formInfo.supervise_time"></DatePicker>
            </FormItem>
          </Col>
          <Col span="6" v-if="formInfo.supervise_start != '6'">
            <FormItem label="本次管控结束日期：">
              <DatePicker type="date" placeholder="选择日期" style="width: 100%" v-model="formInfo.supervise_end_time"></DatePicker>
            </FormItem>
          </Col>
          <Col span="6" v-if="formInfo.supervise_start == '6'">
            <FormItem prop="supervise_end_time">
              <template slot="label">
                本次管控结束日期：
              </template>
              <DatePicker type="date" placeholder="选择日期" style="width: 100%" v-model="formInfo.supervise_end_time"></DatePicker>
            </FormItem>
          </Col>
          <Col span="6" v-if="formInfo.user_control_type1!='2' && formInfo.user_control_type1!='4' ">
            <FormItem prop="arrive_type">
              <template slot="label">
                来沈交通方式：
              </template>
              <Select v-model="formInfo.arrive_type" placeholder="请选择交通方式">
                <Option value="1">火车</Option>
                <Option value="2">轮船</Option>
                <Option value="3">飞机</Option>
                <Option value="4">大巴</Option>
                <Option value="5">自驾</Option>
              </Select>
            </FormItem>
          </Col>
          <Col span="6" v-if="formInfo.user_control_type1!='2' && formInfo.user_control_type1!='4' ">
            <FormItem prop="arrive_type_remark">
              <template slot="label">
                <span>交通方式备注：</span>
                <Icon type="md-help-circle" class="help-tip" @click="showHelp(2)"/>
              </template>
              <Input type="text" v-model="formInfo.arrive_type_remark" placeholder="飞机航班号、火车列次号、客车填出发地；自驾填途径主要省市"/>
            </FormItem>
          </Col>
          <Col span="6" v-if="formInfo.user_control_type1!='2' && formInfo.user_control_type1!='4' ">
            <FormItem label="来沈原因：" prop="arrive_reason">
              <!-- <template slot="label">
                来沈原因：
              </template> -->
              <Select v-model="formInfo.arrive_reason" multiple placeholder="请选择来沈原因" @on-change="arriveReasonChage()">
                <Option value="出差">出差</Option>
                <Option value="就医">就医</Option>
                <Option value="就学">就学</Option>
                <Option value="就业">就业</Option>
                <Option value="旅游">旅游</Option>
                <Option value="探亲">探亲</Option>
                <Option value="访友">访友</Option>
                <Option value="返乡">返乡</Option>
                <Option value="信访">信访</Option>
                <Option value="其他">其他</Option>
              </Select>
            </FormItem>
          </Col>
          <Col span="6" v-if="arrive_reason_remark_show">
            <FormItem prop="arrive_reason_remark">
              <template slot="label">
                来沈原因备注：
              </template>
              <Input type="text" v-model="formInfo.arrive_reason_remark" placeholder="来沈原因备注"/>
            </FormItem>
          </Col>
        </Row>
        <Row :gutter="16">
          <Col span="18">
            <FormItem label="来沈前经过地：">
              <Input type="text" v-model="formInfo.arrive_address"/>
            </FormItem>
          </Col>
          <Col span="24">
            <FormItem label="在沈活动轨迹：">
              <Input type="textarea" v-model="formInfo.arrive_route" :rows="3"/>
            </FormItem>
          </Col>
        </Row>
        <Row :gutter="16">
          <Col span="6" v-if="formInfo.user_control_type1!='2' && formInfo.user_control_type1!='4' ">
            <FormItem prop="province1">
              <template slot="label">
                <span>来源地省：</span>
                <Icon type="md-help-circle" class="help-tip" @click="showHelp(1)"/>
              </template>
              <Select v-model="formInfo.province1" placeholder="请选择来源地省" filterable @on-change="chaneProv(1)">
                <Option v-for="obj in inoutCity.provinceList" :value="obj.name" :key="obj.code">{{obj.name}}</Option>
              </Select>
            </FormItem>
          </Col>
          <Col span="6" v-if="formInfo.user_control_type1!='2' && formInfo.user_control_type1!='4' ">
            <FormItem v-if="inoutCity.city1.length != 0" prop="city1">
              <template slot="label">
                来源地城市：
              </template>
              <Select v-model="formInfo.city1" placeholder="请选择来源地城市" filterable>
                <Option v-for="obj in inoutCity.city1" :value="obj.name" :key="obj.code">{{obj.name}}</Option>
              </Select>
            </FormItem>
            <FormItem label="来源地城市：" v-else>
              <Select v-model="formInfo.city1" placeholder="请选择来源地城市" filterable>
                <Option v-for="obj in inoutCity.city1" :value="obj.name" :key="obj.code">{{obj.name}}</Option>
              </Select>
            </FormItem>
          </Col>
          <Col span="6" v-if="formInfo.user_control_type1!='2' && formInfo.user_control_type1!='4' ">
            <FormItem prop="arrive_time">
              <template slot="label">
                来沈时间：
              </template>
              <DatePicker type="date" placeholder="选择时间" style="width: 100%" v-model="formInfo.arrive_time"></DatePicker>
            </FormItem>
          </Col>
          <Col span="5" v-if="formInfo.supervise_start == '1'">
            <FormItem label="是否贴封条：" prop="is_seal">
              <Select v-model="formInfo.is_seal" placeholder="请选择" @on-change="changeFt" filterable>
                <Option value="0">是</Option>
                <Option value="1">否</Option>
              </Select>
            </FormItem>
          </Col>
        </Row>
        <!-- 上传封条照片 -->
        <Row :gutter="16">
          <Col span="2" v-if="formInfo.is_seal  == '0'">
            <Button type="info" class="uploadDiv" long @click="uploadFtImg">上 传</Button>
          </Col>
          <Col span="2" v-if="temp_photo != '' && formInfo.seal_detail != '' && formInfo.seal_detail != undefined">
            <Button type="success" class="uploadDiv" long @click="picPreviewMol.preShow=true">查 看</Button>
          </Col>
        </Row>
        <Row :gutter="16">
          <Col span="6" v-if="formInfo.supervise_start=='3'">
            <FormItem prop="province2">
              <template slot="label">
                离沈目的地省：
              </template>
              <Select v-model="formInfo.province2" placeholder="请选择离沈目的地省" filterable @on-change="chaneProv(2)">
                <Option v-for="obj in inoutCity.provinceList" :value="obj.name" :key="obj.code">{{obj.name}}</Option>
              </Select>
            </FormItem>
          </Col>
          <Col span="6" v-if="formInfo.supervise_start=='3'">
            <FormItem v-if="inoutCity.city2.length != 0" prop="city2">
              <template slot="label">
                离沈目的地城市：
              </template>
              <Select v-model="formInfo.city2" placeholder="请选择离沈目的地城市" filterable>
                <Option v-for="obj in inoutCity.city2" :value="obj.name" :key="obj.code">{{obj.name}}</Option>
              </Select>
            </FormItem>
            <FormItem label="离沈目的地城市：" v-else>
              <Select v-model="formInfo.city2" placeholder="请选择离沈目的地城市" filterable>
                <Option v-for="obj in inoutCity.city2" :value="obj.name" :key="obj.code">{{obj.name}}</Option>
              </Select>
            </FormItem>
          </Col>
          <Col span="12" v-if="formInfo.supervise_start=='3'">
            <FormItem prop="out_time">
              <template slot="label">
                离沈时间：
              </template>
              <DatePicker type="date" placeholder="选择时间" style="width: 50%" v-model="formInfo.out_time"></DatePicker>
            </FormItem>
          </Col>
          <Col span="6" v-if="formInfo.supervise_start=='3'">
            <FormItem prop="out_type">
              <template slot="label">
                离沈交通方式：
              </template>
              <Select v-model="formInfo.out_type" placeholder="请选择交通方式">
                <Option value="1">火车</Option>
                <Option value="2">轮船</Option>
                <Option value="3">飞机</Option>
                <Option value="4">大巴</Option>
                <Option value="5">自驾</Option>
              </Select>
            </FormItem>
          </Col>
          <Col span="18" v-if="formInfo.supervise_start=='3'">
            <FormItem prop="out_type_remark">
              <template slot="label">
                <span>离沈交通方式备注：</span>
                <Icon type="md-help-circle" class="help-tip" @click="showHelp(2)"/>
              </template>
              <Input type="text" v-model="formInfo.out_type_remark" placeholder="飞机航班号、火车列次号、客车填出发地；自驾填途径主要省市"/>
            </FormItem>
          </Col>
          <Col span="12" v-if="formInfo.supervise_start=='5'">
            <FormItem label="集中隔离时间：" prop="olation_time">
              <DatePicker type="date" placeholder="选择时间" style="width: 100%" v-model="formInfo.olation_time"></DatePicker>
            </FormItem>
          </Col>
          <Col span="12" v-if="formInfo.supervise_start=='5'">
            <FormItem label="集中隔离地点：" prop="olation_address">
              <Input v-model="formInfo.olation_address"></Input>
            </FormItem>
          </Col>
          <Col span="8">
            <FormItem label="集中隔离账号：">
              <Input type="text" v-model="formInfo.olation_company_code"/>
            </FormItem>
          </Col>
          <Col span="8">
            <FormItem label="所在社区编号：">
              <Input v-model="formInfo.company_code"></Input>
            </FormItem>
          </Col>
          <Col span="8">
            <FormItem label="所在社区名称：">
              <Input type="text" v-model="formInfo.company_name"/>
            </FormItem>
          </Col>
        </Row>

        <div class="title-style">服务信息</div>
        <!-- <Row :gutter="16">
          <Col span="6">
            <FormItem>
              <template slot="label">
                核酸检测：
              </template>
              <RadioGroup v-model="formInfo.nucleic_acid">
                <Radio label="0">未检测</Radio>
                <Radio label="1">已检测</Radio>
              </RadioGroup>
            </FormItem>
          </Col>
          <Col span="6" v-if="formInfo.nucleic_acid=='1'">
            <FormItem prop="detection_1_result" label="第一次检测结果：">
              <Select v-model="formInfo.detection_1_result" placeholder="第一次检测结果">
                <Option value="1">阴性</Option>
                <Option value="2">阳性</Option>
                <Option value="3">待出结果</Option>
                <Option value="4">未检测</Option>
              </Select>
            </FormItem>
          </Col>
          <Col span="6" v-if="formInfo.nucleic_acid=='1'">
            <FormItem prop="detection_2_result" label="第二次检测结果：">
              <Select v-model="formInfo.detection_2_result" placeholder="第二次检测结果">
                <Option value="1">阴性</Option>
                <Option value="2">阳性</Option>
                <Option value="3">待出结果</Option>
                <Option value="4">未检测</Option>
              </Select>
            </FormItem>
          </Col>
        </Row> -->
        <Row :gutter="16">
          <Col span="6">
            <FormItem>
              <template slot="label">
                血清检测：
              </template>
              <RadioGroup v-model="formInfo.serum_state">
                <Radio label="0">未检测</Radio>
                <Radio label="1">已检测</Radio>
              </RadioGroup>
            </FormItem>
          </Col>
          <Col span="6" v-if="formInfo.serum_state=='1'">
            <FormItem prop="serum_1_result" label="第一次检测结果：">
              <Select v-model="formInfo.serum_1_result" placeholder="第一次检测结果">
                <Option value="1">阴性</Option>
                <Option value="2">阳性</Option>
                <Option value="3">待出结果</Option>
                <Option value="4">未检测</Option>
              </Select>
            </FormItem>
          </Col>
          <Col span="6" v-if="formInfo.serum_state=='1'">
            <FormItem prop="serum_2_result" label="第二次检测结果：">
              <Select v-model="formInfo.serum_2_result" placeholder="第二次检测结果">
                <Option value="1">阴性</Option>
                <Option value="2">阳性</Option>
                <Option value="3">待出结果</Option>
                <Option value="4">未检测</Option>
              </Select>
            </FormItem>
          </Col>
        </Row>
        <Row :gutter="16">
          <!-- <Col span="6">
            <FormItem>
              <template slot="label">
                人员状态：
              </template>
              <Select v-model="formInfo.illness_state">
                <Option value="1">疑似病例</Option>
                <Option value="2">确诊病例</Option>
                <Option value="3">死亡</Option>
                <Option value="4">治愈</Option>
                <Option value="5">正常</Option>
              </Select>
            </FormItem>
          </Col> -->
          <Col span="12">
            <FormItem label="人员状态备注：">
              <Input type="text" v-model="formInfo.illness_state_remark"/>
            </FormItem>
          </Col>
          <Col span="6">
            <FormItem>
              <template slot="label">
                是否持有健康通行码（绿码）：
              </template>
              <Select v-model="formInfo.is_have_healthcard">
                <Option value="1">是</Option>
                <Option value="0">否</Option>
              </Select>
            </FormItem>
          </Col>
        </Row>
        <Row :gutter="16">
          <Col span="6">
            <FormItem label="谈话人姓名：">
              <Input type="text" v-model="formInfo.first_talk_user" placeholder="请输入谈话人姓名"/>
            </FormItem>
          </Col>
          <Col span="12">
            <FormItem label="初接谈话时间：" >
              <DatePicker type="datetime" format="yyyy-MM-dd HH:mm:ss" placeholder="选择时间" v-model="formInfo.first_talk_time" style="width: 300px"></DatePicker>
            </FormItem>
          </Col>
        </Row>
        <!-- <Row :gutter="16"> -->
          <!-- <Col span="6">
            <FormItem>
              <template slot="label">
                密切接触人员：
              </template>
              <Select v-model="formInfo.isfollow">
                <Option value="1">是</Option>
                <Option value="0">否</Option>
                <Option value="2">按行动轨迹主动申请隔离人员</Option>
              </Select>
            </FormItem>
          </Col>
          <Col span="6" v-if="formInfo.isfollow=='1'">
            <FormItem prop="follow_person" label="密接相关人：">
              <Select v-model="formInfo.follow_person" placeholder="请选择密接相关人" filterable>
                <Option v-for="obj in followPersonList" :value="obj.value" :key="obj.label">{{obj.label}}</Option>
              </Select>
              <Select v-model="formInfo.follow_person" placeholder="密接相关人：">
                <Option value="1">阴性</Option>
                <Option value="2">阳性</Option>
                <Option value="3">待出结果</Option>
              </Select>
            </FormItem>
          </Col>
          <Col span="6" v-if="formInfo.isfollow=='1'">
            <FormItem prop="follow_level" label="密接等级：">
              <Select v-model="formInfo.follow_level" placeholder="密接等级：">
                <Option value="1">一级密接</Option>
                <Option value="2">二级密接</Option>
                <Option value="3">三级密接</Option>
              </Select>
            </FormItem>
          </Col> -->
          <!-- <Col span="6">
            <FormItem prop="risk_groups" label="是否风险人群：">
              <Select v-model="formInfo.risk_groups" placeholder="请选择是否风险人群：">
                <Option value="1">是</Option>
                <Option value="0">否</Option>
              </Select>
            </FormItem>
          </Col> -->
        <!-- </Row> -->
        <Row v-if="formInfo.supervise_start === '2'">
          <Col span="6">
            <FormItem label="寻访社区工作者姓名：" prop="protect_user">
              <Input type="text" v-model="formInfo.protect_user" placeholder="请输入寻访社区工作者姓名"/>
            </FormItem>
          </Col>
          <Col span="6">
            <FormItem label="寻访社区工作者联系方式：" prop="protect_tel">
              <Input type="text" v-model="formInfo.protect_tel" placeholder="请输入寻访社区工作者联系方式"/>
            </FormItem>
          </Col>
        </Row>
        <Row :gutter="16" v-if="formInfo.supervise_start !== '2'">
          <Col span="6">
            <FormItem label="包保人社区工作者姓名：" prop="protect_user">
              <Input type="text" v-model="formInfo.protect_user" placeholder="请输入包保人社区工作者姓名"/>
            </FormItem>
          </Col>
          <Col span="6">
            <FormItem label="包保人医务工作者姓名：" prop="protect_user1">
              <Input type="text" v-model="formInfo.protect_user1" placeholder="请输入包保人医务工作者姓名"/>
            </FormItem>
          </Col>
          <Col span="6">
            <FormItem label="包保人公安民警姓名：" prop="protect_user2">
              <Input type="text" v-model="formInfo.protect_user2" placeholder="请输入包保人公安民警姓名"/>
            </FormItem>
          </Col>
          <Col span="6">
            <FormItem label="包保人志愿者姓名：" prop="protect_user3">
              <Input type="text" v-model="formInfo.protect_user3" placeholder="请输入包保人志愿者姓名"/>
            </FormItem>
          </Col>
        </Row>
        <Row :gutter="16" v-if="formInfo.supervise_start !== '2'">
          <Col span="6">
            <FormItem label="包保人社区工作者联系方式：" prop="protect_tel">
              <Input type="text" v-model="formInfo.protect_tel" placeholder="请输入包保人社区工作者联系方式"/>
            </FormItem>
          </Col>
          <!-- <span v-if="formInfo.affirm_state"> -->
          <Col span="6">
            <FormItem label="包保人医务工作者联系方式：" prop="protect_tel1">
              <Input type="text" v-model="formInfo.protect_tel1" placeholder="请输入包保人医务工作者联系方式"/>
            </FormItem>
          </Col>
          <Col span="6">
            <FormItem label="包保人公安民警联系方式：" prop="protect_tel2">
              <Input type="text" v-model="formInfo.protect_tel2" placeholder="请输入包保人公安民警联系方式"/>
            </FormItem>
          </Col>
          <Col span="6">
            <FormItem label="包保人志愿者联系方式：" prop="protect_tel3">
              <Input type="text" v-model="formInfo.protect_tel3" placeholder="请输入包保人志愿者联系方式"/>
            </FormItem>
          </Col>
        </Row>
        <Row :gutter="16">
          <!-- <Col span="6">
            <FormItem>
              <template slot="label">
                目前状态：
              </template>
              <Select v-model="formInfo.state">
                <Option v-for="obj in stateList" :value="obj.id" :key="obj.id">{{obj.name}}</Option>
              </Select>
            </FormItem>
          </Col> -->
          <Col span="12">
            <FormItem v-if="formInfo.state=='4'" prop="focus_place">
              <template slot="label">
                集中安置点：
              </template>
              <Select v-model="formInfo.focus_place" placeholder="请选择集中安置点" filterable>
                <Option v-for="obj in focusPlaceList" :value="obj.name" :key="obj.id">[{{obj.area}}]{{obj.name}}</Option>
              </Select>
            </FormItem>
          </Col>
        </Row>

        <div v-show="!addFlag">
          <div class="title-style">
            <span>同行人情况</span>
            <Button class="add-btn" size="small" type="info" @click="editRow({}, '1', '同行人员情况')"
                    shape="circle" icon="md-add"></Button>
          </div>
          <Table :loading="relevantPerson.partnerLoading" border :columns="columnsPerson"
                :data="relevantPerson.partnerList" size="small">
            <template slot="action" slot-scope="{ row }">
              <Button type="success" class="table-mr5" size="small" @click="editRow(row, '1', '同行人员情况')">编辑</Button>
              <Button type="error" size="small" @click="deleteRow(row, '1')">删除</Button>
            </template>
          </Table>

          <div class="title-style">
            <span>抵沈后接触人员</span>
            <Button class="add-btn" size="small" type="info" @click="editRow({}, '2', '接触人员情况')"
                    shape="circle" icon="md-add"></Button>
          </div>
          <Table :loading="relevantPerson.contactLoading" border :columns="columnsPerson"
                :data="relevantPerson.contactList" size="small">
            <template slot="action" slot-scope="{ row }">
              <Button type="success" class="table-mr5" size="small" @click="editRow(row, '2', '接触人员情况')">编辑</Button>
              <Button type="error" size="small" @click="deleteRow(row, '2')">删除</Button>
            </template>
          </Table>
          <!-- <div class="title-style">
            <span>密接人员情况</span>
            <Button class="add-btn" size="small" type="info" @click="editRow({}, '3', '密接人员情况')"
                    shape="circle" icon="md-add"></Button>
          </div>
          <Table :loading="relevantPerson.jzLoading" border :columns="columns"
                 :data="relevantPerson.jzList" size="small">
            <template slot="action" slot-scope="{ row }">
              <Button type="success" class="table-mr5" size="small" @click="editRow(row, '3', '密接人员情况')">编辑</Button>
              <Button type="error" size="small" @click="deleteRow(row, '3')">删除</Button>
            </template>
          </Table> -->
        </div>
        <Row type="flex" justify="center" :gutter="16">
          <Col span="3">
            <Button type="primary" :loading="saving" class="save-btn mr20" long @click="saveInfo">保 存</Button>
          </Col>
          <Col span="3">
            <Button type="error" class="save-btn" long @click="back">返 回</Button>
          </Col>
          <Col span="3">
            <Button type="error" class="save-btn" long @click="deleteUserInfo()">删 除</Button>
          </Col>
        </Row>
        <Modal v-model="modalInfo.show" :title="modalInfo.title" width="700">
          <Form label-position="right">
            <Row class="bench_search">
              <Col span="7" class="ivu-form-item-label">姓名：</Col>
              <Col span="12" class="ivu-form-item-content">
                <Input type="text" v-model="modalInfo.name" placeholder="请输入姓名"/>
              </Col>
            </Row>
            <Row class="bench_search">
              <Col span="7" class="ivu-form-item-label">证件号码：</Col>
              <Col span="12" class="ivu-form-item-content">
                <Input type="text" v-model="modalInfo.card_no" placeholder="请输入证件号码"/>
              </Col>
            </Row>
            <Row class="bench_search">
              <Col span="7" class="ivu-form-item-label">联系方式：</Col>
              <Col span="12" class="ivu-form-item-content">
                <Input type="text" v-model="modalInfo.mobile" placeholder="请输入联系方式"/>
              </Col>
            </Row>
            <Row class="bench_search" v-if="leave">
              <Col span="7" class="ivu-form-item-label">密接等级：</Col>
              <Select v-model="modalInfo.leave" style="width:200px">
                <Option v-for="item in leaveList" :value="item.value" :key="item.value">{{ item.label }}</Option>
              </Select>
            </Row>
            <Row class="bench_search">
              <Col span="7" class="ivu-form-item-label">备注：</Col>
              <Col span="12" class="ivu-form-item-content">
                <Input type="textarea" v-model="modalInfo.remark" :rows="2"/>
              </Col>
            </Row>
          </Form>
          <div slot="footer">
            <Button type="success" @click="saveModalInfo">确定</Button>
            <Button type="error" @click="modalInfo.show=false">关闭</Button>
          </div>
        </Modal>
        <Modal v-model="uploadModShow" title="图片上传" :closable="false">
          <Upload multiple action="http://120.27.63.37:38081/api/ac/file/fileCommonService/upLoadFiles" :before-upload="beforeUpload">
            <Button icon="ios-cloud-upload-outline">上传图片</Button>
            <span style="margin-left: 250px">请上传小于8M的图片</span>
          </Upload>
          <img :src="temp_photo" style="width: 100%"/>
        </Modal>
        <!-- 图片查看模态框 -->
      <Modal v-model="picPreviewMol.preShow" :closable="false" :styles="{top: '20px'}" width="532">
        <img :src="temp_photo" alt="">
        <!-- <div slot="footer" style="text-align: center" >
            <Button @click="picPreviewMol.preShow=false">关闭</Button>
        </div> -->
      </Modal>
      </Form>
      <Row type="flex" justify="center" :gutter="16" v-if="!editFlag">
          <Col span="3">
            <Button type="error" class="save-btn" long @click="back">返 回</Button>
          </Col>
        </Row>
    </div>
</template>

<script>
import validateData from './validate'
import { grid_downlist, date2str, date0str } from '@/api/eventlist'
import { getSign, createUpLoadFiles, getCityList } from '@/api/common'
import { createuserinfo, getuserinfo, getuserinfoApp, banduserlist, updateuserinfoforadmin, userinfoByCardNo,
  deleteUserInfo, createuserband, updatebanduser, delbanduser, getDictList } from '@/api/yi-qing-fang-kong'

export default {
  name: 'add',
  data () {
    return {
      leave: false,
      leaveList: [
        {
          value: '1',
          label: '一级密接'
        },
        {
          value: '2',
          label: '二级密接'
        },
        {
          value: '3',
          label: '三级密接'
        }
      ],
      fromApp: false,
      editFlag: true,
      addFlag: true,
      saving: false,
      arrive_reason_remark_show: false,
      company_type: '1',
      ruleValidate: validateData.ruleValidate,
      ruleValidate1: validateData.ruleValidate1,
      occupationList: validateData.formData.occupationList,
      focusPlaceList: validateData.formData.focusPlaceList,
      formInfo: {
        follow_person: ''
      },
      isshowfollow_person: false,
      ishave99: false,
      oldsupervise_start: '',
      userControlType1: [],
      userControlType2: [],
      addressInfo: { list1: [], list2: [], list3: [] },
      inoutCity: { provinceList: [], city1: [], city2: [] },
      columnsPerson: [
        { title: '序号', type: 'index', width: 80, align: 'center' },
        { title: '姓名', key: 'name', width: 150 },
        { title: '证件号码', key: 'card_no', width: 200 },
        { title: '联系方式', key: 'mobile', width: 200 },
        { title: '备注', key: 'remark' },
        { title: '操作', align: 'center', width: 200, slot: 'action', fixed: 'right' }
      ],
      columns: [
        { title: '序号', type: 'index', width: 80, align: 'center' },
        { title: '姓名', key: 'name', width: 150 },
        { title: '证件号码', key: 'card_no', width: 200 },
        { title: '联系方式', key: 'mobile', width: 200 },
        { title: '密接等级', key: 'leave', width: 200 },
        { title: '备注', key: 'remark' },
        { title: '操作', align: 'center', width: 200, slot: 'action', fixed: 'right' }
      ],
      relevantPerson: {
        partnerLoading: false,
        contactLoading: false,
        jzLoading: false,
        partnerList: [],
        contactList: []
      },
      modalInfo: { show: false },
      temp_photo: '',
      uploadModShow: false,
      stateList: [],
      arriveAddressTypeList: [],
      superviseTypeList: [],
      followPersonList: [],
      isTransferList: [],
      helpTipList: [
        '2020年1月开始的常住起居地城市',
        '火车列次号、飞机航班号、客车出发地及时间、自驾出发时间途径地等等',
        '原起居地址（观察地），在沈期间常住地址'
      ],
      monitoring_typeList: [],
      // 图片要件预览弹出框控制器
      picPreviewMol: {
        preShow: false,
        pic_urls: [],
        picIndex: 0
      },
      temp_supervise_end_time: '',
      flag_supervise_state: false, // 监控管控状态是否发生变化
      jcglInfo: {
        show: false,
        supervise_end_time: ''
      },
      total_param: {},
      exchange_type: ''
    }
  },
  watch: {
    $route: function (to, from) {
      this.company_type = to.query.user_type
      this.exchange_type = to.query.exchange_type
      this.formInfo.state = to.query.state || '1'
      if (to.query.state === '4') {
        this.stateList = validateData.formData.curStateList[1]
      } else {
        this.stateList = validateData.formData.curStateList[0]
      }
    }
  },
  methods: {
    editRow (row, type, title) {
      this.leave = false
      this.modalInfo.title = title
      this.modalInfo.type = type
      this.modalInfo.name = row.name
      this.modalInfo.card_no = row.card_no
      this.modalInfo.mobile = row.mobile
      this.modalInfo.remark = row.remark
      this.modalInfo.leave = row.leave
      this.modalInfo.id = row.id
      if (type === '3') {
        this.leave = true
      }
      this.modalInfo.show = true
    },
    changeuserControlType1 () {
      this.formInfo.cold_chain_user = '0'
      let param = {
        pageNo: 1,
        pageSize: 60,
        type: 'xgc_usercontroltype' + this.formInfo.user_control_type1
      }
      getDictList(param).then(res => {
        if (res.data.errcode === 0) {
          this.userControlType2 = res.data.data.results
        } else {
          this.$Notice.error({ title: '查询失败' })
        }
      })
      if (this.userControlType2.length > 0) {
        this.formInfo.user_control_type2 = '1'
      } else {
        this.formInfo.user_control_type2 = ''
      }
    },
    getuserControlType1 () {
      let param = {
        pageNo: 1,
        pageSize: 60,
        type: 'xgc_usercontroltype' + this.formInfo.user_control_type1
      }
      getDictList(param).then(res => {
        if (res.data.errcode === 0) {
          this.userControlType2 = res.data.data.results
        } else {
          this.$Notice.error({ title: '查询失败。' })
        }
      })
    },
    deleteRow (row, type) {
      this.$Modal.confirm({
        title: '删除后无法找回，确认操作！',
        onOk: () => {
          delbanduser(row.id).then(res => {
            if (res.data.data) {
              this.$Notice.success({ title: '删除成功' })
              this.banduser(row.user_id, type)
            } else {
              this.$Notice.error({ title: '删除失败' })
            }
          })
        }
      })
    },
    changeuser_control_type2 () {
      if (this.formInfo.user_control_type1 === '2' && this.formInfo.user_control_type2 === '3') {
        this.formInfo.supervise_start = '1'
      }
      if (this.formInfo.user_control_type1 === '2' && this.formInfo.user_control_type2 !== '11' && this.formInfo.user_control_type2 !== '12') {
        this.isshowfollow_person = true
      } else {
        this.isshowfollow_person = false
      }
    },
    changeFt () {
      if (this.formInfo.is_seal === '1') {
        this.formInfo.seal_detail = ''
        this.temp_photo = ''
      }
    },
    changeGkState () {
      console.log(this.formInfo.supervise_start, '管控状态')
      if (this.formInfo.supervise_start === '6') {
        this.formInfo.supervise_end_time = ''
        this.flag_supervise_state = true
      } else {
        this.flag_supervise_state = false
      }
    },
    monitoringTypesChage () {
      let ishave999 = false
      this.formInfo.monitoring_types.forEach((item, index) => {
        if (item === '99') {
          ishave999 = true
        }
      })
      console.log('ishave999', ishave999)
      this.ishave99 = ishave999
    },
    arriveReasonChage () {
      let arrive_reason_remark_show = false
      this.formInfo.arrive_reason.forEach((item, index) => {
        if (item === '其他') {
          arrive_reason_remark_show = true
        }
      })
      console.log('arrive_reason_remark_show', arrive_reason_remark_show)
      this.arrive_reason_remark_show = arrive_reason_remark_show
    },
    saveModalInfo () {
      if (!this.modalInfo.name) {
        this.$Notice.warning({ title: '错误', desc: '请填写姓名' })
        return
      }
      let param = {
        id: this.modalInfo.id,
        user_id: this.formInfo.id,
        name: this.modalInfo.name,
        card_no: this.modalInfo.card_no,
        mobile: this.modalInfo.mobile,
        type: this.modalInfo.type,
        remark: this.modalInfo.remark,
        leave: this.modalInfo.leave
      }
      if (param.id) {
        updatebanduser(param).then(res => {
          if (res.data.data) {
            this.modalInfo.show = false
            this.$Notice.success({ title: '修改成功' })
            this.banduser(param.user_id, param.type)
          } else {
            this.$Notice.error({ title: '修改失败' })
          }
        })
      } else {
        createuserband(param).then(res => {
          if (res.data.data) {
            this.modalInfo.show = false
            this.$Notice.success({ title: '添加成功' })
            this.banduser(param.user_id, param.type)
          } else {
            this.$Notice.error({ title: '添加失败' })
          }
        })
      }
    },
    perChange (index, flag) {
      if (index === 3 || (this.company_type === '2' && index === 2)) {
        return
      }
      let temparea = this.formInfo['area' + index]
      if (!temparea) {
        return
      }
      let templist = this.addressInfo['list' + index]
      let tempdata = {}
      for (let i = 0; i < templist.length; i++) {
        if (temparea === templist[i].title) {
          tempdata = templist[i]
          break
        }
      }
      this.getDownAddress(tempdata.id, index + 1, flag)
    },
    getDownAddress (pid, index, flag) {
      let param = {
        pid: pid,
        pageNo: 1,
        pageSize: 200
      }
      grid_downlist(param).then(res => {
        if (res.data.data) {
          this.addressInfo['list' + index] = res.data.data.results
          if (flag) {
            this.perChange(index, flag)
          }
        } else {
          this.$Notice.error({ title: '查看失败', desc: '查询地址信息失败' })
        }
      })
    },
    getuserbycardno (card_no) {
      let tempaaa = userinfoByCardNo
      tempaaa(card_no).then(res => {
        if (res.data.data) {
          this.formInfo = res.data.data
          this.formInfo.area1 = res.data.data.area
          this.formInfo.area2 = res.data.data.street
          this.formInfo.area3 = res.data.data.community
          this.formInfo.area5 = res.data.data.community
          this.formInfo.province1 = res.data.data.originate_province
          this.formInfo.province2 = res.data.data.out_province
          this.formInfo.city1 = res.data.data.originate_city
          this.formInfo.city2 = res.data.data.out_city
          this.formInfo.nucleic_acid = this.formInfo.nucleic_acid || '0'
          this.ruleValidate.card_no[0].card_type = this.formInfo.card_type
          this.getCity(null, 'provinceList', true)
          this.getDownAddress(0, 1, true)
        } else {
          this.$Notice.error({ title: '查询失败' })
        }
      })
    },
    deleteUserInfo () {
      this.$Modal.confirm({
        title: '是否删除',
        content: '删除后无法恢复请确认！',
        onOk: () => {
          let tempaaa = deleteUserInfo
          console.log('id:' + this.formInfo.id)
          tempaaa(this.formInfo.id).then(res => {
            if (res.data.data) {
              this.$Notice.success({ title: '删除成功' })
              this.$router.go(-1)
            } else {
              this.$Notice.error({ title: '删除失败' })
            }
          })
        },
        onCancel: () => {
        }
      })
    },
    saveInfo () {
      if (!this.editFlag) {
        this.$Notice.warning({ title: '非法操作！' })
        return
      }
      // if (this.formInfo.card_type === '1') {
      //   console.log('shenfezheng')
      //   var reg = /^[1-9]\d{7}((0\d)|(1[0-2]))(([0|1|2]\d)|3[0-1])\d{3}$|^[1-9]\d{5}[1-9]\d{3}((0\d)|(1[0-2]))(([0|1|2]\d)|3[0-1])\d{3}([0-9]|X)$/
      //   // var reg1 = /^1[45][0-9]{7}|([P|p|S|s]\d{7})|([S|s|G|g]\d{8})|([Gg|Tt|Ss|Ll|Qq|Dd|Aa|Ff]\d{8})|([H|h|M|m]\d{8，10})$/
      //   var reg1 = /^([a-zA-z]|[0-9]){5,17}$/
      //   if (reg.test(this.formInfo.card_no) === false && reg1.test(this.formInfo.card_no) === false) {
      //     this.$Notice.warning({ title: '身份证格式不正确！' })
      //     return
      //   }
      // }
      this.saving = true
      if (this.formInfo.supervise_start === '6' && this.formInfo.user_control_type2 === '') {
        this.formInfo.user_control_type2 = '-'
      }
      if (this.formInfo.supervise_start !== '1') {
        this.formInfo.is_transfer = ''
      }
      if (this.formInfo.user_control_type1 !== '2') {
        this.formInfo.follow_person = ''
        this.formInfo.follow_level = ''
      }
      if (this.formInfo.user_control_type1 === '2') {
        if (this.formInfo.follow_person === undefined && this.isshowfollow_person) {
          this.saving = false
          const content = '<p>请选择密接人</p>'
          const errorTitle = '错误提示'
          this.$Modal.error({
            title: errorTitle,
            content: content
          })
          return
        }
      }
      if (this.formInfo.nucleic_acid !== '1') {
        this.formInfo.detection_1_result = ''
        this.formInfo.detection_2_result = ''
      }
      if (this.formInfo.serum_state !== '1') {
        this.formInfo.serum_1_result = ''
        this.formInfo.serum_2_result = ''
      }
      if (this.formInfo.user_control_type2 === '-') {
        this.formInfo.user_control_type2 = ''
      }
      if (this.formInfo.is_seal === '0') {
        if (!this.temp_photo || this.temp_photo === undefined) {
          this.saving = false
          const content = '<p>请上传封条图片</p>'
          const errorTitle = '错误提示'
          this.$Modal.error({
            title: errorTitle,
            content: content
          })
          return
        }
      }
      // if (this.formInfo.is_monitoring !== '0') {
      //   this.formInfo.monitoring_type = ''
      //   this.formInfo.monitoring_type_detail = ''
      // }
      // if (this.formInfo.monitoring_type !== '999') {
      //   this.formInfo.monitoring_type_detail = ''
      // }
      if (this.formInfo.is_monitoring !== '0') {
        this.formInfo.monitoring_types = []
        this.formInfo.monitoring_type_detail = ''
      }
      if (this.formInfo.monitoring_types.length > 0) {
        let ishave999 = false
        let monitoring_types1 = ''
        this.formInfo.monitoring_types.forEach((item, index) => {
          monitoring_types1 += item + ','
          if (item === '99') {
            ishave999 = true
          }
        })
        if (!ishave999) {
          this.formInfo.monitoring_type_detail = ''
        }
        monitoring_types1 = monitoring_types1.substr(0, monitoring_types1.length - 1)
        this.formInfo.monitoring_type = monitoring_types1
      } else {
        this.formInfo.monitoring_type = ''
      }
      if (this.formInfo.arrive_reason && this.formInfo.arrive_reason.length > 1) {
        let arrive_reason1 = ''
        let ishaveqita = false
        this.formInfo.arrive_reason.forEach((item, index) => {
          arrive_reason1 += item + ','
          if (item === '其他') {
            ishaveqita = true
          }
        })
        console.log('3333')
        if (!ishaveqita) {
          this.formInfo.arrive_reason_remark = ''
        }
        console.log('44444')
        arrive_reason1 = arrive_reason1.substr(0, arrive_reason1.length - 1)
        console.log(arrive_reason1, 'arrive_reason1')
        this.formInfo.arrive_reason = arrive_reason1
      } else {
        this.formInfo.arrive_reason = ''
      }
      console.log('555')
      if (this.formInfo.serum_state === '2') {
        this.formInfo.protect_tel1 = ''
        this.formInfo.protect_tel2 = ''
        this.formInfo.protect_tel3 = ''
        this.formInfo.protect_user1 = ''
        this.formInfo.protect_user2 = ''
        this.formInfo.protect_user3 = ''
      }
      // console.log('55555', this.flag_supervise_state, this.temp_supervise_end_time, date2str(this.formInfo.supervise_end_time))
      // if (this.flag_supervise_state === true) {
      //   if (this.temp_supervise_end_time === date2str(this.formInfo.supervise_end_time)) {
      //     const content = '<p>请选择本次管控结束日期</p>'
      //     const errorTitle = '错误提示'
      //     this.$Modal.error({
      //       title: errorTitle,
      //       content: content
      //     })
      //     return
      //   }
      // }
      let param = {
        user_type: this.company_type,
        name: this.formInfo.name,
        sex: this.formInfo.sex,
        card_type: this.formInfo.card_type,
        card_no: this.formInfo.card_no,
        occupation: this.formInfo.occupation,
        tel: this.formInfo.tel,
        area: this.formInfo.area1,
        street: this.formInfo.area2,
        community: this.company_type === '1' ? this.formInfo.area3 : this.formInfo.area5,
        address: this.formInfo.address,
        arrive_time: date2str(this.formInfo.arrive_time),
        arrive_type: this.formInfo.arrive_type,
        arrive_type_remark: this.formInfo.arrive_type_remark,
        arrive_address_type: this.formInfo.arrive_address_type,
        arrive_address: this.formInfo.arrive_address,
        arrive_route: this.formInfo.arrive_route,
        protect_tel: this.formInfo.protect_tel,
        hot: this.formInfo.hot,
        referral: this.formInfo.referral,
        referral_address: this.formInfo.referral_address,
        state: this.formInfo.state,
        isfollow: this.formInfo.isfollow,
        illness_state: this.formInfo.illness_state,
        illness_state_remark: this.formInfo.illness_state_remark,
        // inout_state: this.formInfo.inout_state,
        supervise_start: this.formInfo.supervise_start,
        supervise_time: date2str(this.formInfo.supervise_time),
        supervise_end_time: date2str(this.formInfo.supervise_end_time),
        originate_province: this.formInfo.province1,
        originate_city: this.inoutCity.city1.length === 0 ? ' ' : this.formInfo.city1,
        out_province: this.formInfo.province2,
        out_city: this.inoutCity.city2.length === 0 ? ' ' : this.formInfo.city2,
        out_time: date2str(this.formInfo.out_time),
        out_type: this.formInfo.out_type,
        out_type_remark: this.formInfo.out_type_remark,
        focus_place: this.formInfo.focus_place,
        concentration_type: this.formInfo.concentration_type,
        concentration_type_remark: this.formInfo.concentration_type_remark,
        nucleic_acid: this.formInfo.nucleic_acid,
        is_have_healthcard: this.formInfo.is_have_healthcard,
        olation_time: date2str(this.formInfo.olation_time),
        olation_address: this.formInfo.olation_address,
        follow_person: this.formInfo.follow_person,
        follow_level: this.formInfo.follow_level,
        is_transfer: this.formInfo.is_transfer,
        detection_1_result: this.formInfo.detection_1_result,
        detection_2_result: this.formInfo.detection_2_result,
        serum_state: this.formInfo.serum_state,
        serum_1_result: this.formInfo.serum_1_result,
        serum_2_result: this.formInfo.serum_2_result,
        risk_groups: this.formInfo.risk_groups,
        is_monitoring: this.formInfo.is_monitoring,
        protect_user: this.formInfo.protect_user,
        protect_user1: this.formInfo.protect_user1,
        protect_user2: this.formInfo.protect_user2,
        protect_user3: this.formInfo.protect_user3,
        protect_tel1: this.formInfo.protect_tel1,
        protect_tel2: this.formInfo.protect_tel2,
        protect_tel3: this.formInfo.protect_tel3,
        monitoring_type: this.formInfo.monitoring_type,
        // monitoring_type: monitoring_types,
        monitoring_type_detail: this.formInfo.monitoring_type_detail,
        user_control_type1: this.formInfo.user_control_type1,
        user_control_type2: this.formInfo.user_control_type2,
        cold_chain_user: this.formInfo.cold_chain_user,
        first_talk_time: date0str(this.formInfo.first_talk_time),
        first_talk_user: this.formInfo.first_talk_user,
        seal_detail: this.temp_photo,
        is_seal: this.formInfo.is_seal,
        arrive_reason: this.formInfo.arrive_reason,
        arrive_reason_remark: this.formInfo.arrive_reason_remark,
        company_code: this.formInfo.company_code,
        olation_company_code: this.formInfo.olation_company_code,
        id: this.formInfo.id
      }
      this.updateuser(param)
      this.saving = false
    },
    confirmJc () { // 承诺解除管控
      this.oldsupervise_start = '6'
      if (this.addFlag || this.fromApp) {
        this.total_param.del_flag = '1'
        this.createuser(this.total_param)
      } else {
        this.total_param.id = this.formInfo.id
        this.updateuser(this.total_param)
      }
    },
    cancelJc () { // 解除管控
      this.saving = false
      this.jcglInfo.show = false
    },
    getuser (id) {
      let tempaaa = getuserinfo
      if (this.fromApp) {
        tempaaa = getuserinfoApp
      }
      tempaaa(id).then(res => {
        if (res.data.data) {
          this.formInfo = res.data.data
          this.oldsupervise_start = this.formInfo.supervise_start
          this.formInfo.area1 = res.data.data.area
          this.formInfo.area2 = res.data.data.street
          this.formInfo.area3 = res.data.data.community
          this.formInfo.area5 = res.data.data.community
          this.formInfo.province1 = res.data.data.originate_province
          this.formInfo.province2 = res.data.data.out_province
          this.formInfo.city1 = res.data.data.originate_city
          this.formInfo.city2 = res.data.data.out_city
          this.formInfo.nucleic_acid = this.formInfo.nucleic_acid || '0'
          this.formInfo.serum_state = this.formInfo.serum_state || '0'
          this.temp_photo = res.data.data.seal_detail
          this.temp_supervise_end_time = res.data.data.supervise_end_time
          if (this.formInfo.user_control_type1 === '2' && this.formInfo.user_control_type2 !== '11') {
            this.isshowfollow_person = true
          } else {
            this.isshowfollow_person = false
          }
          console.log(this.temp_photo, '封条照片')
          if (this.exchange_type === 'true' && (res.data.data.user_control_type1 === '5' || res.data.data.user_control_type1 === '6')) {
            this.formInfo.user_control_type1 = ''
            this.formInfo.user_control_type2 = ''
            console.log(this.formInfo.user_control_type1, '村往社区转')
          }
          if (this.formInfo.monitoring_type) {
            let monitoring_types = this.formInfo.monitoring_type.split(',')
            this.formInfo.monitoring_types = monitoring_types
            this.monitoringTypesChage()
          } else {
            this.formInfo.monitoring_types = []
          }
          if (this.formInfo.arrive_reason) {
            let arrive_reasons = this.formInfo.arrive_reason.split(',')
            this.formInfo.arrive_reason = arrive_reasons
            this.arriveReasonChage()
          } else {
            this.formInfo.arrive_reason = []
          }
          if (this.formInfo.cold_chain_user) {
            this.formInfo.cold_chain_user = res.data.data.cold_chain_user
          } else {
            this.formInfo.cold_chain_user = '0'
          }
          this.ruleValidate.card_no[0].card_type = this.formInfo.card_type
          this.getCity(null, 'provinceList', true)
          this.getDownAddress(0, 1, true)
          this.getuserControlType1()
          this.formInfo.user_control_type2 = res.data.data.user_control_type2
        } else {
          this.$Notice.error({ title: '查询失败' })
        }
      })
    },
    createuser (param) {
      createuserinfo(param).then(res => {
        if (res.data.errcode === 0) {
          this.$Notice.success({ title: '添加成功' })
          this.formInfo.id = res.data.data.id
          this.addFlag = false
          this.$router.go(-1)
        } else {
          this.$Notice.error({ title: '添加失败', desc: res.data.errmsg })
        }
        this.saving = false
      })
    },
    updateuser (param) {
      updateuserinfoforadmin(param).then(res => {
        if (res.data.errcode === 0) {
          this.addFlag = false
          this.$Notice.success({ title: '修改成功' })
          this.getuserbycardno(param.card_no)
        } else {
          this.$Notice.error({ title: '修改失败', desc: res.data.errmsg })
        }
        this.saving = false
      })
      this.saving = false
    },
    banduser (user_id, type, loading) {
      let param = {
        type: type,
        user_id: user_id,
        pageNo: 1,
        pageSize: 200
      }
      let tempstr = type + ''
      // tempstr = tempstr === '1' ? 'partner' : 'contact'
      if (tempstr === '1') {
        tempstr = 'partner'
      } else if (tempstr === '2') {
        tempstr = 'contact'
      } else if (tempstr === '3') {
        tempstr = 'jz'
      }
      this.relevantPerson[tempstr + 'Loading'] = true
      banduserlist(param).then(res => {
        if (res.data.data) {
          this.relevantPerson[tempstr + 'List'] = res.data.data.results
          this.relevantPerson[tempstr + 'Loading'] = false
        } else {
          this.$Notice.error({ title: '查询人员列表失败' })
          this.relevantPerson[tempstr + 'Loading'] = false
        }
      })
    },
    back () {
      this.$router.go(-1)
    },
    chaneProv (index) {
      let temparea = this.formInfo['province' + index]
      if (!temparea) {
        return
      }
      let templist = this.inoutCity.provinceList
      let tempdata = {}
      for (let i = 0; i < templist.length; i++) {
        if (temparea === templist[i].name) {
          tempdata = templist[i]
          break
        }
      }
      this.getCity(tempdata.code, 'city' + index, false)
    },
    getCity (code, listname, flag) {
      getCityList({ code: code }).then(res => {
        if (res.data.errcode === 0) {
          this.inoutCity[listname] = res.data.data
          if (flag) {
            if (this.formInfo.province1) {
              this.chaneProv(1)
            }
            if (this.formInfo.province2) {
              this.chaneProv(2)
            }
          }
        } else {
          this.$Notice.error({ title: '查询失败' })
        }
      })
    },
    showHelp (index) {
      let tip = this.helpTipList[index - 1] || '暂无提示信息'
      this.$Modal.info({ title: '提示信息', content: tip, okText: '知道了！' })
    },
    // 上传图片前转base64
    beforeUpload (file) {
      let upPicData = {
        filePath: 'itemorder/yiqing/' + this.formInfo.id,
        fileName: file.name
      }
      const reader = new FileReader()
      reader.readAsDataURL(file)
      reader.onload = () => {
        let index = reader.result.indexOf('base64,') + 7
        upPicData.file = reader.result.substring(index)
        this.upPic(upPicData)
      }
      return false
    },
    // 上传图片
    upPic (obj) {
      let timeStep = new Date().getTime().toString()
      let param = {
        filePath: obj.filePath,
        fileName: obj.fileName,
        timestamp: timeStep
      }
      getSign(param).then(res => {
        if (res.data.errcode === 0) {
          let uploadParam = {
            sign: res.data.data.sign,
            timestamp: timeStep,
            filePath: obj.filePath,
            fileName: obj.fileName,
            file: obj.file
          }
          createUpLoadFiles(res.data.data.docking_url, uploadParam).then(res => {
            if (res.data.errcode === 0) {
              this.temp_photo = res.data.data
              this.$Notice.success({ title: '上传成功' })
            } else {
              this.$Notice.error({ title: '上传失败', desc: res.data.data.msg })
            }
          })
        } else {
          this.$Notice.error({ title: '上传失败', desc: res.data.data.msg })
        }
      })
    },
    arriveTypeList () {
      this.arriveAddressTypeList = []
      this.superviseTypeList = []
      this.followPersonList = []
      this.isTransferList = []
      let param = {
        pageNo: 1,
        pageSize: 60,
        type: 'arrive_address_type'
      }
      let param1 = {
        pageNo: 1,
        pageSize: 60,
        type: 'supervise_start'
      }
      let param2 = {
        pageNo: 1,
        pageSize: 60,
        type: 'follow_person'
      }
      let param3 = {
        pageNo: 1,
        pageSize: 60,
        type: 'is_transfer'
      }
      let param4 = {
        pageNo: 1,
        pageSize: 60,
        type: 'monitoring_type'
      }
      let param5 = {
        pageNo: 1,
        pageSize: 60,
        type: 'xgc_usercontroltype'
      }
      getDictList(param).then(res => {
        if (res.data.errcode === 0) {
          this.arriveAddressTypeList = res.data.data.results
        } else {
          this.$Notice.error({ title: '查询失败' })
        }
      })
      getDictList(param1).then(res => {
        if (res.data.errcode === 0) {
          let List = res.data.data.results
          List.forEach((item, index) => {
            console.log(item.value, item.label)
            if (item.value === '7') {
              List.splice(index, 1)
            }
            if (item.value === '4') {
              List.splice(index, 1)
            }
          })
          List.forEach((item, index) => {
            console.log(item.value, item.label)
            if (item.value === '4') {
              List.splice(index, 1)
            }
          })
          List.forEach((item, index) => {
            console.log(item.value, item.label)
            if (item.value === '5') {
              List.splice(index, 1)
              this.superviseTypeList = List
            } else {
              this.superviseTypeList = List
            }
          })
        } else {
          this.$Notice.error({ title: '查询失败' })
        }
      })
      getDictList(param2).then(res => {
        if (res.data.errcode === 0) {
          this.followPersonList = res.data.data.results
        } else {
          this.$Notice.error({ title: '查询失败' })
        }
      })
      getDictList(param3).then(res => {
        if (res.data.errcode === 0) {
          this.isTransferList = res.data.data.results
        } else {
          this.$Notice.error({ title: '查询失败' })
        }
      })
      getDictList(param4).then(res => {
        if (res.data.errcode === 0) {
          this.monitoring_typeList = res.data.data.results
        } else {
          this.$Notice.error({ title: '查询失败' })
        }
      })
      getDictList(param5).then(res => {
        let that = this
        if (res.data.errcode === 0) {
          if (this.company_type === '1') {
            that.userControlType1 = []
            res.data.data.results.forEach(function (temp1, index) {
              if (temp1.value !== '5' && temp1.value !== '6') {
                that.userControlType1.push(temp1)
              }
            })
          } else {
            this.userControlType1 = res.data.data.results
          }
        } else {
          this.$Notice.error({ title: '查询失败' })
        }
      })
    },
    uploadFtImg () { // 上传封条照片
      this.uploadModShow = true
    },
    // 查看图片原图功能
    originalGraph () {
      window.open(this.picPreviewMol.pic_urls[this.picPreviewMol.picIndex])
    }
  },
  mounted () {
    let queryData = this.$route.query || {}
    this.company_type = queryData.user_type || '1'
    this.exchange_type = queryData.exchange_type || ''
    console.log(this.exchange_type, 'this.exchange_typethis.exchange_type')
    this.fromApp = queryData.app === '1'
    if (queryData.state === '4') {
      this.stateList = validateData.formData.curStateList[1]
    } else {
      this.stateList = validateData.formData.curStateList[0]
    }
    this.arriveTypeList()
    // edit：修改，info：查看，add：添加(其他值算添加)
    if (queryData.what === 'edit') {
      this.editFlag = true
      this.addFlag = false
      this.getuser(queryData.id)
      this.banduser(queryData.id, 1)
      this.banduser(queryData.id, 2)
      this.banduser(queryData.id, 3)
    } else if (queryData.what === 'info') {
      this.editFlag = false
      this.addFlag = false
      this.getuser(queryData.id)
      this.banduser(queryData.id, 1)
      this.banduser(queryData.id, 2)
      this.banduser(queryData.id, 3)
    } else {
      this.editFlag = true
      this.addFlag = true
      this.formInfo = {
        sex: '男',
        card_type: '1',
        state: queryData.state || '1',
        isfollow: '0',
        hot: '0',
        referral: '0',
        illness_state: '5',
        // inout_state: '1',
        supervise_start: '1',
        follow_level: '3',
        detection_1_result: '4',
        detection_2_result: '4',
        nucleic_acid: '0',
        serum_state: '0',
        serum_1_result: '4',
        serum_2_result: '4',
        is_transfer: '1',
        is_have_healthcard: '1',
        risk_groups: '0',
        arrive_address_type: queryData.arrive_address_type || '3',
        monitoring_types: [],
        arrive_reason: []
      }
      this.getCity(null, 'provinceList', false)
      this.getDownAddress(0, 1, false)
    }
  }
}
</script>

<style scoped>
  .title-style {
    padding: 8px 12px;
    background-color: #ecf8ff;
    border-radius: 4px;
    border-left: 5px solid #50bfff;
    margin: 15px 0;
    font-size: 16px;
    width: 100%;
  }
  .table-mr5 {
    margin-right: 5px;
  }
  .add-btn {
    float: right;
    font-size: 15px;
  }
  .save-btn {
    margin: 20px
  }
  .mr20 {
    margin-right: 20px;
  }
  .bench_search {
    margin-bottom: 10px;
  }
  .help-tip {
    cursor:pointer;
    color: #5cadff;
  }
  .red-star {
    font-family: SimSun;
    color: #f00;
    margin-right: 4px;
  }
  .uploadDiv {
    margin-bottom: 10px;
  }
</style>
